import prompt from '@system.prompt';
import router from '@system.router';

export default {
    data: {
        searchValue:"凄美地",
        isLogin:false,
        headPicture:"/common/images/img6.jpg",
        nikeName:"与尔",
        phoneNumber:"",
        sex:"女",
        icon:{
            home:"/common/icon/homeSelected.png",
            like:"/common/icon/like.png",
            my:"/common/icon/my.png",
        },
        songList:[
            {
                song:"给我一个吻",
                singer:"宋亚轩",
                img:"/common/images/img1.jpg",
                videoUrl:"/common/videos/video1.mp4",
                isLike:false
            },
            {
                song:"兰花草",
                singer:"宋亚轩",
                img:"/common/images/img2.jpg",
                videoUrl:"/common/videos/video2.mp4",
                isLike:false
            },
            {
                song:"我怀念的",
                singer:"宋亚轩",
                img:"/common/images/img3.jpg",
                videoUrl:"/common/videos/video1.mp4",
                isLike:false
            },
            {
                song:"凄美地",
                singer:"宋亚轩",
                img:"/common/images/img4.jpg",
                videoUrl:"/common/videos/video1.mp4",
                isLike:false
            },
            {
                song:"Forever Young",
                singer:"宋亚轩",
                img:"/common/images/img5.jpg",
                videoUrl:"/common/videos/video1.mp4",
                isLike:false
            },
        ],
        indexList:[]
    },
    onInit(){
        this.indexList=this.songList;
    },
    searchSubmit(e){
        var item;
        this.indexList=[];
        for(item of this.songList){
            if(item.song.includes(e.text)||item.singer.includes(e.text)){
                this.indexList.push(item);
            }
        }
    },
    searchChange(e){
        if(e.newText==''||e.newText==null){
            this.indexList=this.songList;
        }
    },
    tabChange(e){
        if(e.index==0){
            this.icon.home="/common/icon/homeSelected.png";
            this.icon.like="/common/icon/like.png";
            this.icon.my="/common/icon/my.png";
        }else if(e.index==1){
            this.icon.home="/common/icon/home.png";
            this.icon.like="/common/icon/likeSelected.png";
            this.icon.my="/common/icon/my.png";
        }else if(e.index==2){
            this.icon.home="/common/icon/home.png";
            this.icon.like="/common/icon/like.png";
            this.icon.my="/common/icon/mySelected.png";
        }
    },

    songPage(item){
        router.push({
            uri:"pages/songPage/songPage",
            params:{url:item.videoUrl}
        })
    },
    likeClick(item){
        if(this.isLogin){
            item.isLike=!item.isLike;
        } else{
            prompt.showToast({
                message: "请先登录",
                duration: 2000,
            });
        }
    },
    login(){
        router.push({
            uri:"pages/login/login",
        })
    }
}
